
// 新增基础功能函数
function openFile() {
    document.getElementById('file-input').click();
}

function saveFile() {
    const code = editor.getValue();
    const file_name_input = document.getElementById('file-name-input');
    const blob = new Blob([code], { type: 'text/plain;charset=utf-8' });
    const url = URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = file_name_input.value + '.gs'; // 修改文件扩展名为 .gs
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    URL.revokeObjectURL(url);
}
function loadFile(event) {
    const file = event.target.files[0];
    if (file) {
        const reader = new FileReader();
        reader.onload = function(e) {
            const content = e.target.result;
            editor.setValue(content);
        };
        reader.readAsText(file);
    }
}